package com.weilele.leisure.time.net

import com.weilele.leisure.time.CommonHttp
import com.weilele.leisure.time.bean.*
import com.weilele.leisure.time.bean.BaseResp
import com.weilele.mvvm.utils.net.createRetrofitApi
import okhttp3.RequestBody
import retrofit2.http.*

object ApiInstance : Api by Api.self
object ApiInstance2 : Api by Api.self2
interface Api {
    companion object {
        val self by lazy { createRetrofitApi<Api>(CommonHttp.BASE_URL) }
        val self2 by lazy { createRetrofitApi<Api>(CommonHttp.BASE_URL_2) }
        private val emptyBody by lazy { hashMapOf<String, String>() }
    }

    @GET("/api/v2/advers")
    @Headers("url_type:server")
    suspend fun advers(@QueryMap map: Map<String?, String?>?): BaseResp<List<AdInfoBean>>

    @POST("/api/v2/bind/email")
    @Headers("url_type:server")
    suspend fun bindEmail(@Body requestBody: RequestBody?): BaseResp<BindResultBean>

    @POST("/api/v2/bind/code")
    @Headers("url_type:server")
    suspend fun bindPromoteCode(@Body requestBody: RequestBody?): BaseResp<BindResultBean>

    @POST("/api/v2/bind/tel")
    @Headers("url_type:server")
    suspend fun bindTel(@Body requestBody: RequestBody?): BaseResp<BindResultBean>

    @GET("/api/v2/order/{orderno}")
    @Headers("url_type:server")
    suspend fun checkPayStatus(@Path("orderno") str: String?): BaseResp<PayStatusBean>

    @POST("/api/v2/collect/video/{id}")
    @Headers("url_type:server")
    suspend fun collect(
        @Path("id") str: String?,
        @Body requestBody: RequestBody?
    ): BaseResp<Any?>

    @POST("/api/v2/vip/active")
    @Headers("url_type:server")
    suspend fun exchangeVip(@Body requestBody: RequestBody?): BaseResp<ExchangeVipBean>

    @POST("/api/v2/find/cates")
    @Headers("url_type:server")
    suspend fun findCates(@Body requestBody: RequestBody?): BaseResp<VideoCateBean>

    @POST("/api/v2/reset/password")
    @Headers("url_type:server")
    suspend fun findPassword(@Body requestBody: RequestBody?): BaseResp<Any>

    @POST("/api.php/v2/find/mingxing")
    @Headers("url_type:cmsSdk")
    suspend fun findStar(@Body requestBody: RequestBody?): BaseResp<StarListBean>

    @GET("/api/v2/setting")
    @Headers("url_type:config")
    suspend fun getAppConfig(): BaseResp<Any?>

    @GET("/api/v2/v/c/t/{type}")
    @Headers("url_type:server")
    suspend fun getAppVersion(@Path("type") str: String?): BaseResp<AppVersionBean>

    @GET("/api.php/v2/banners")
    @Headers("url_type:cmsSdk")
    suspend fun getBanner(@QueryMap map: Map<String?, String?>?): BaseResp<BannerBean>

    @GET("/api/v2/gjs")
    @Headers("url_type:server")
    suspend fun getGjs(): BaseResp<List<VideoGJBean>>

    @POST("/api.php/v2/mx/videos")
    @Headers("url_type:server")
    suspend fun getMxVideo(@Body requestBody: RequestBody?): BaseResp<VideoListBean>

    @POST("/api/v2/orders")
    @Headers("url_type:server")
    suspend fun getOrders(@Body requestBody: RequestBody?): BaseResp<OrderListBean>

    @GET("/api/v2/page/{page_id}")
    @Headers("url_type:config")
    suspend fun getPageById(@Path("page_id") str: String?): BaseResp<PageByIdBean>

    @GET("/api/v2/page/{page_id}")
    @Headers("url_type:config")
    suspend fun getPageByIdTv(@Path("page_id") str: String?): BaseResp<TVplayBean>

    @GET("/api/v2/payments")
    @Headers("url_type:server")
    suspend fun getPayType1(): BaseResp<PayType1Bean>

    @GET("/api/v2/payments/proxy")
    @Headers("url_type:server")
    suspend fun getPayType2(): BaseResp<PayType2Bean>

    @POST("/api/v2/user/recommend/records")
    @Headers("url_type:server")
    suspend fun getPromoteRecords(@Body requestBody: RequestBody?): BaseResp<RecomendListBean>

    @POST("/api/v2/collect/actors")
    @Headers("url_type:server")
    suspend fun getStarCollects(@Body requestBody: RequestBody?): BaseResp<StarListBean>

    @POST("/api.php/v2/mx/details")
    @Headers("url_type:cmsSdk")
    suspend fun getStarDetail(@Body requestBody: RequestBody?): BaseResp<StarDetailBean>

    @GET("/api/v2/user/details")
    @Headers("url_type:server")
    suspend fun getUserInfo(): BaseResp<UserInfoBean>

    @POST("/api/v2/collect/videos")
    @Headers("url_type:server")
    suspend fun getVideoCollects(@Body requestBody: RequestBody?): BaseResp<VideoListBean>

    @POST("/api.php/v2/video")
    @Headers("url_type:cmsSdk")
    suspend fun getVideoDetail(@Query("video_id") video_id: Int): BaseResp<VideoDetailBean>

    @POST("/api.php/v2/videos")
    @Headers("url_type:cmsSdk")
    suspend fun getVideos(@Body map:HashMap<String,Any?>): BaseResp<VideoListBean>

    @POST("/api.php/v2/guess")
    @Headers("url_type:cmsSdk")
    suspend fun guessVideos(@Body requestBody: RequestBody?): BaseResp<VideoListBean>

    @POST("/api/v2/login")
    @Headers("url_type:server")
    suspend fun login(@Body requestBody: RequestBody?): BaseResp<LoginInfoBean>

    @POST("/api/v2/order")
    @Headers("url_type:server")
    suspend fun payOrder1(@Body requestBody: RequestBody?): BaseResp<PayResultBean>

    @POST("/api/v2/order/report")
    @Headers("url_type:server")
    suspend fun payReport(@Body requestBody: RequestBody?): BaseResp<Any>

    @POST("/api/v2/video/playreport")
    @Headers("url_type:server")
    suspend fun playreport(@Body requestBody: RequestBody?): BaseResp<Any>

    /**
     * 注册用户，获取token，放在请求头
     */
    @POST("/api/v2/preregist")
    @Headers("url_type:server")
    suspend fun preregist(@Body map: HashMap<String, String> = emptyBody): BaseResp<LoginInfoBean>

    @POST("/api/v2/regist")
    @Headers("url_type:server")
    suspend fun register(@Body requestBody: RequestBody?): BaseResp<LoginInfoBean>

    @POST("/api/v2/discollect/video/{id}")
    @Headers("url_type:server")
    suspend fun unCollect(
        @Path("id") str: String?,
        @Body requestBody: RequestBody?
    ): BaseResp<Any>
}